import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MiniProgramCategoryVO, MiniProgramCategoryForm, MiniProgramCategoryQuery, WechatCategorySelectVO } from '@/api/platform/miniProgramCategory/types';

/**
 * 查询小程序类目信息列表
 * @param query
 * @returns {*}
 */

export const listMiniProgramCategory = (query?: MiniProgramCategoryQuery): AxiosPromise<MiniProgramCategoryVO[]> => {
  return request({
    url: '/platform/miniProgramCategory/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询小程序类目信息详细
 * @param id
 */
export const getMiniProgramCategory = (id: string | number): AxiosPromise<MiniProgramCategoryVO> => {
  return request({
    url: '/platform/miniProgramCategory/' + id,
    method: 'get'
  });
};

/**
 * 新增小程序类目信息
 * @param data
 */
export const addMiniProgramCategory = (data: MiniProgramCategoryForm) => {
  return request({
    url: '/platform/miniProgramCategory',
    method: 'post',
    data: data
  });
};

/**
 * 修改小程序类目信息
 * @param data
 */
export const updateMiniProgramCategory = (data: MiniProgramCategoryForm) => {
  return request({
    url: '/platform/miniProgramCategory',
    method: 'put',
    data: data
  });
};

/**
 * 删除小程序类目信息
 * @param id
 */
export const delMiniProgramCategory = (id: string | number | Array<string | number>) => {
  return request({
    url: '/platform/miniProgramCategory/' + id,
    method: 'delete'
  });
};


/**
 * 微信类目下拉
 * @param data
 */
export const wxCategorySelect = (baseId: string | number): AxiosPromise<WechatCategorySelectVO> => {
  return request({
    url: '/platform/miniProgramCategory/wxCategorySelect?baseId=' + baseId,
    method: 'get'
  });
};

/**
 * 批量小程序类目信息
 * @param data
 */
export const batchSave = (data: MiniProgramCategoryForm) => {
  return request({
    url: '/platform/miniProgramCategory/batchUpdateCategory',
    method: 'post',
    data: data
  });
};